package com.jh.microservice.reactive;

import reactor.core.publisher.Flux;
import reactor.core.scheduler.Scheduler;
import reactor.core.scheduler.Schedulers;

public class ReactorDemo {
    public static void main(String[] args) throws Exception{
        Flux.just(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
                .filter(v -> v % 2 == 1)
                .map(v -> v - 1)
                .reduce(Integer::sum)
                .subscribeOn(Schedulers.elastic())
                .subscribeOn(Schedulers.parallel())
                .subscribe(ReactorDemo::print);

        Thread.sleep(1000);
    }

    public static void print(Object message) {
        System.out.printf("【线程：%s】：%s\n", Thread.currentThread().getName(), message);
    }

}
